//
//  HomeBannerCell.m
//  PPDL
//
//  Created by 王洋 on 2019/7/23.
//  Copyright © 2019 王洋. All rights reserved.
//

#import "HomeBannerCell.h"

@interface HomeBannerCell ()<SDCycleScrollViewDelegate>

@end

@implementation HomeBannerCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.backgroundColor = [UIColor whiteColor];
        [self layout];
    }
    return self;
}

- (void)layout {
    
    [self addSubview:self.bannerView];
    
    [self.bannerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.bottom.mas_equalTo(0);
    }];
    
}


- (void)configBannerCellWithImageArray:(NSMutableArray *)arr {
    
    self.bannerView.imageURLStringsGroup = arr;
}


- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index {
    
    if (self.CycleImgClickedBlock) {
        self.CycleImgClickedBlock(index);
    }
}


- (SDCycleScrollView *)bannerView {
    if (!_bannerView) {
        _bannerView = [[SDCycleScrollView alloc] init];
        _bannerView.bannerImageViewContentMode = UIViewContentModeScaleToFill;
        _bannerView.autoScrollTimeInterval = 5;
        _bannerView.placeholderImage = [UIImage imageNamed:@"placeholder_longrect"];
        _bannerView.delegate = self;
    }
    return _bannerView;
}

- (void)awakeFromNib {
    [super awakeFromNib];

    self.selectionStyle = UITableViewCellSelectionStyleNone;

}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
